<section id="widget-grid" class="">
    <div class="row">
    	<div id="list-alert">
        </div>
    </div>
    <div class="row">
        <article class="col-xs-24 col-sm-24 col-md-24 col-lg-12">
            <table id="jqgrid"></table>
            <div id="pjqgrid"></div>
        </article>
    </div>
</section>
<div class="modal fade" id="unitModal" tabindex="-1" role="dialog" aria-labelledby="unitModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="" id="dialogmodal">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="unitModalLabel">
                   实例单元详细信息
                </h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>单元名称</th>
                            <th>单元类型</th>
                            <th>实例状态</th>
                        </tr>
                        </thead>
                        <tbody id="mainframestate">
                        </tbody>
                    </table>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    pageSetUp();
    loadScript("js/plugin/jqgrid/grid.locale-en.min.js", function(){
    	loadScript("js/plugin/jqgrid/jquery.jqGrid.min.js", function(){
    		loadScript("js/create-jqgrid.js", function(){ 
    			sendGet("/upm_manager/v1.0/monitor/component/hosts?site="+getSession("siteId"),createGridHostStatus,ListAlert,null);
    		});
    	});
    });
    
    $('#unitModal').on("show.bs.modal", function(e){
    	ListAlertClear();
    	$("#mainframestate").empty();
    	sendGet("/upm_manager/v1.0/monitor/component/host/containers?host="+$(e.relatedTarget).data('unit-id'),createGridUnitDetail,ListAlert,null);
    });
    
    function showReturn(){
    	sendGet("/upm_manager/v1.0/monitor/component/hosts?site="+getSession("siteId"),reloadGrid,ListAlert,null);
	}
    
    function reloadGrid(data){
	   	ListAlertClear();
	   	var jq_data=data['data'];  	
	   	$("#jqgrid").clearGridData().setGridParam({data:jq_data}).trigger("reloadGrid");
    }
    
	clearInterval(flag);
	var flag = setInterval(showReturn, setTime);
</script>